#include "_commen.hpp"

int main()
{
    umask(0);
    int n = mkfifo(fifoname.c_str(), mode);
    if (n != 0)
    {
        // 创建失败，查看原因
        std::cout << "error:" << errno << ":" << strerror(errno) << endl;
        return 1;
    }
    // 创建成功
    cout << "创建成功" << endl;
    int m = open(fifoname.c_str(), O_RDONLY);
    cout << "打开文件成功，可以开始通信" << endl;

    char buf[NUM] = {0};
    while (true)
    {
        ssize_t num = read(m, buf, sizeof(buf) - 1);
        buf[sizeof(buf) - 1] = 0;
        cout << buf;
        fflush(stdout);
    }
    close(m);

    return 0;
}